home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine CD 1995 / Archive Magazine CD 1995.iso / discs / prog_disc / volume_5 / issue_10 / shared_c / s / AEx1 next >
Encoding:
Text File  |  1992-05-13  |  1.1 KB  |  41 lines

  1. ;*******************************************************************************
  2. ;*
  3. ;* AEx1.s
  4. ;* © Simon Callan, 1992
  5. ;*
  6. ;* This program is intended as an example of using the Shared C Library from
  7. ;* assembler.
  8. ;*
  9. ;* int main(void)
  10. ;*  {
  11. ;*  printf("hello world\n");
  12. ;*  return 0;
  13. ;*  }
  14. ;*
  15. ;*******************************************************************************
  16.  
  17.           GET       @.Header.Registers
  18.  
  19.           AREA      |ASM$$Code|,CODE,READONLY
  20.  
  21.           EXPORT    main
  22.           IMPORT    printf
  23.           IMPORT    |x$stack_overflow|
  24.  
  25. main      MOV       ip,sp               ; Generate APCS-R stack frame
  26.           STMFD     sp!,{fp,ip,lr,pc}
  27.           SUB       fp,ip,#4
  28.  
  29.           CMP       sp,sl               ; Have we reached the end of the stack (very unlikely at this point) ?
  30.           BLLT      |x$stack_overflow|  ; Yes
  31.  
  32.           ADR       a1,text             ; a1 points to text
  33.           BL        printf              ; call printf
  34.  
  35. finished  MOV       a1,#0
  36.           LDMEA     fp,{fp,sp,pc}^
  37.  
  38. text      =         "hello world",10,0
  39.  
  40.           END
  41.